/*
 * Created on 2004-9-26
 */
package hzjbbis.framework.xml;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * @since 1.0
 * @author lix
 */
public class ElementType implements XmlNodeType {

    private final TagName _tagName;

    /**
     * @return ElementType
     */
    public static XmlNodeType getInstance(TagName tagName) {
        return new ElementType(tagName);
    }

    private ElementType(TagName tagName) {
        _tagName = tagName;
    }

    /**
     * @see hzjbbis.framework.xml.XmlNodeType#isText()
     */
    public boolean isText() {
        return false;
    }

    /**
     * @see hzjbbis.framework.xml.XmlNodeType#isElement()
     */
    public boolean isElement() {
        return true;
    }

    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return "is element XmlNodeType;" + _tagName;
    }

    /**
     * @see hzjbbis.framework.xml.XmlNodeType#getTagName()
     */
    public TagName getTagName() {
        return _tagName;
    }

    /**
     * @see java.lang.Object#equals(Object)
     */
    public boolean equals(Object object) {
        if (!(object instanceof ElementType)) {
            return false;
        }
        ElementType rhs = (ElementType) object;
        return new EqualsBuilder().append(this._tagName, rhs._tagName)
                .isEquals();
    }

    /**
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {
        return new HashCodeBuilder(-409075873, 751854107).append(this._tagName)
                .toHashCode();
    }
}